package com.pure.controller
{
	import com.pure.model.UserProxy;
	import com.pure.model.vo.UserVO;
	import com.pure.service.SaveUserService;
	
	import mx.rpc.AsyncToken;
	
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.command.SimpleCommand;

	public class SaveUserCommand extends SimpleCommand
	{
		override public function execute( notification:INotification ):void
		{
			var msg:UserVO = notification.getBody() as UserVO;
			
			// if you need to communicate with the server, please code here
			//sendMessageToServer(msg);
			
			var service:SaveUserService = new SaveUserService();
			var serviceCallToken:AsyncToken = service.getServerResult(msg);//AsyncToken(d_Up_Object.create(info));
			serviceCallToken.addResponder(service);
		}
		
    	public function onSuccess(e:Object):void
    	{
			userProxy = UserProxy( facade.retrieveProxy( UserProxy.NAME ) );
			userProxy.saveItem(e as UserVO);
    	}
		
		private var userProxy:UserProxy;
	}
}